-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract fatal notification into fatalError service, add support for EuiToast notifications #15749
Extract fatal notification into fatalError service, add support for EuiToast notifications #15749
Conversation
15d1300
to
28a127c
Compare
@nreese Could you take a look at my changes to Dashboard and let me know what you think? @thomasneirynck Could you do the same with Visualize? @bmcconaghy Would you mind doing the same with Management? |
jenkins, test this |
a14dde4
to
62ce88e
Compare
@@ -30,7 +30,7 @@ export function FetchNowProvider(Private, Promise) { | |||
if (!req.started) return req; | |||
return req.retry(); | |||
})) | |||
.catch(courierNotifier.fatal); | |||
.catch(error => fatalError(error, location)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like the optimizer is tripping over the uninitialized location variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh shoot! Good catch, thanks. We should add a linting rule for that!
e08f9d5
to
0e0b7da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good from the dashboard perspective. Just a comment about using single vs double quotes.
What are the plans for all of the skipped tests?
@@ -43,7 +43,11 @@ uiRoutes | |||
this.field = this.indexPattern.fields.byName[fieldName]; | |||
|
|||
if (!this.field) { | |||
notify.error(this.indexPattern + ' does not have a "' + fieldName + '" field.'); | |||
toastNotifications.add({ | |||
title: `"${this.indexPattern.title}" index pattern doesn't have a scripted field called "${fieldName}"`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to use single quotes to be consistent with the confirm modals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Great catch. Will fix.
@nreese I consider this level of skipped tests to be a blocker. I'm going to dig into them to identify the cause for their failure (I have a feeling it has something to do with the |
a3d42cc
to
c576066
Compare
b7252d9
to
545589d
Compare
💔 Build Failed |
jenkins, test this |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
…uiToast notifications (elastic#15749) * Reorganize notify/lib files. Extract fatal notification into a fatalError service. * Convert notify/lib tests to use Jest. * Add ToastNotifications, GlobalToastList, and documentation. * Remove notify.info method. * Add createFirstIndexPatternPrompt. * Update testSubjects.exists to accept a timeout argument. * Skip some flaky tests.
…uiToast notifications (#15749) (#16330) * Reorganize notify/lib files. Extract fatal notification into a fatalError service. * Convert notify/lib tests to use Jest. * Add ToastNotifications, GlobalToastList, and documentation. * Remove notify.info method. * Add createFirstIndexPatternPrompt. * Update testSubjects.exists to accept a timeout argument. * Skip some flaky tests.
…rt for EuiToast notifications (elastic#15749)" This reverts commit 6e9fc73.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edited toast text. Format is:
object type > object name > was/were >past tense of action
@@ -183,14 +184,18 @@ app.directive('dashboardApp', function ($injector) { | |||
$scope.addVis = function (hit, showToast = true) { | |||
dashboardStateManager.addNewPanel(hit.id, 'visualization'); | |||
if (showToast) { | |||
notify.info(`Visualization successfully added to your dashboard`); | |||
toastNotifications.addSuccess('Added visualization to your dashboard'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Visualization was added to your dashboard
} | ||
}; | ||
|
||
$scope.addSearch = function (hit) { | ||
dashboardStateManager.addNewPanel(hit.id, 'search'); | ||
notify.info(`Search successfully added to your dashboard`); | ||
toastNotifications.addSuccess({ | ||
title: 'Added saved search to your dashboard', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saved search was added to your dashboard
@@ -268,7 +273,11 @@ app.directive('dashboardApp', function ($injector) { | |||
.then(function (id) { | |||
$scope.kbnTopNav.close('save'); | |||
if (id) { | |||
notify.info(`Saved Dashboard as "${dash.title}"`); | |||
toastNotifications.addSuccess({ | |||
title: `Saved '${dash.title}'`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dashboard '${dash.title}' was saved
@@ -416,7 +416,11 @@ function discoverController( | |||
$scope.kbnTopNav.close('save'); | |||
|
|||
if (id) { | |||
notify.info('Saved Data Source "' + savedSearch.title + '"'); | |||
toastNotifications.addSuccess({ | |||
title: `Saved '${savedSearch.title}'`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data source "searchSearch.title" was saved
@@ -82,11 +81,17 @@ uiModules.get('apps/management') | |||
}); | |||
|
|||
if (fieldsAdded > 0) { | |||
notify.info(fieldsAdded + ' script fields created'); | |||
toastNotifications.addSuccess({ | |||
title: 'Created script fields', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that maybe this should be "added" See the button guidelines for a description.
Also, the Kibana "Create Index" page uses "scripted field"
Recommendation:
Scripted field "fieldname" was added
or
Scripted field was added
Prefer one line over title and text
Toasts will automatically be dismissed after a brief delay, but if for some reason you want to dismiss a toast, you can use the returned toast from one of the `add` methods and then pass it to `remove`. | ||
|
||
```js | ||
const toast = toastNotifications.add('Saved document'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your document was saved
|
||
```js | ||
toastNotifications.add({ | ||
title: 'Saved document', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your document was saved
|
||
```js | ||
toastNotifications.add({ | ||
title: 'Saved document', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your document was saved
Only you have editing privileges. Edit permisson (no ending period cause its a link)
|
||
```js | ||
toastNotifications.addSuccess({ | ||
title: 'Saved document', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your document was saved
// Select the text to be copied. If the copy fails, the user can easily copy it manually. | ||
const copyTextarea = $document.find(selector)[0]; | ||
copyTextarea.select(); | ||
|
||
try { | ||
const isCopied = document.execCommand('copy'); | ||
if (isCopied) { | ||
notify.info('URL copied to clipboard.'); | ||
toastNotifications.add({ | ||
title: 'URL copied to clipboard', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL was copied to the clipboard
Relates to #15721. Partially addresses #8194. This simplifies the notification system (making it easier to integrate non-fatal notifications with EuiToasts) and adds support for displaying EuiToasts.
To-do
data-test-subj
, in a non-brittle wayGlobalToastList
Functional test changes
Avoid calling
clickToastOK()
This method has traditionally been used as a hacky proxy for the successful creation of a dashboard, visualization, etc. Successful actions will trigger toasts instead of banner notifications, moving forward. So this method will become less and less useful and will eventually be removed.
Saving dashboards and visualizations is self-confirming
By the same token, now when you call
saveDashboard()
orsaveVisualization()
, the method will wait until the confirmation toast appears and resolve successfully only once it appears. This means you no longer need to call these methods and thenclickToastOK()
afterwards.New
getBreadcrumbPageTitle()
methodThe last breadcrumb behaves as a page title for many apps. This method will return the text within this breadcrumb, essentially returning the page title value.
Make string-checking tests more robust
Visualization tests now leverage this method to confirm the name of a newly-created visualization. But they do so by asserting that the value contains the name of the visualization, not that it matches it. A strict equality match is brittle and will result in a test failure if we decorate the page title with information in addition to the visualization name. But the UX is still intact so the test should not fail. Checking that the page title contains the visualization name ensures that the test will still pass in this case. We should apply similar tactics where possible.